/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-10-13 08:30:36
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-12-28 10:04:22
 * @FilePath: \adminstration\src\Common\Modal\TwoModalList\Organization.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import { API_LIST } from '../../Api/Api'
import { commonTableList, BuiltInData } from '../config'
import { TwoAddBtn, ThrDeleteBtn, ModifyDataState } from '../options'

export const BeamProduceRecordDetail = async ({ upDataEvent, data, Permission }) => {
    const ClientData = JSON.parse(localStorage.getItem('ClientData'))
    let dataList = {
        type: '梁生产工序',
        hideInSearch: true,
        pageSize: 10,
        params: {},
        classification: 'TableModal',
        get: API_LIST()['getBeamProduceRecordDetail'],
        additional: { key: 'BeamProduceRecordUuid', value: 'uuid' },
        options: [
            Permission.findIndex(v => v.uuid === 'dbcacb26-1bde-4d14-8ebc-ee63e9abb9a2') !== -1 && (
                <TwoAddBtn
                    upDataEvent={upDataEvent}
                    title="新增工序"
                    ThrKey="ThrModal"
                    value="BeamProduceRecordDetail"
                    data={data}
                />
            ),
        ],
        columns: [
            {
                title: '工序',
                dataIndex: 'processUuid',
                search: false,
                valueType: 'select',
                valueEnum: ClientData.process,
            },
            {
                title: '台座',
                dataIndex: 'beamSeatName',
                search: false,
                valueType: 'select',
            },
            {
                title: '生产日期',
                dataIndex: 'produceDate',
                search: false,
                valueType: 'Date',
                width: 200,
            },
            {
                title: '状态',
                dataIndex: 'auditStatus',
                search: false,
                valueType: 'select',
                width: 150,
                valueEnum: BuiltInData.auditStatus,
            },
            commonTableList.createUserName,
            commonTableList.createTime,

            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 300,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { auditStatus } = record
                    return [
                        auditStatus === 0 && (
                            <ModifyDataState
                                key="1"
                                title="合格"
                                type="auditStatus"
                                upDataEvent={upDataEvent}
                                data={{
                                    api: 'putBeamProduceRecordDetail',
                                    params: { uuid: record.uuid, auditStatus: 1, beamProduceRecordUuid: data.uuid },
                                    path: [record.uuid],
                                }}
                            />
                        ),
                        auditStatus === 0 && (
                            <ModifyDataState
                                key="2"
                                title="不合格"
                                type="auditStatus"
                                upDataEvent={upDataEvent}
                                data={{
                                    api: 'putBeamProduceRecordDetail',
                                    params: { uuid: record.uuid, auditStatus: 2, beamProduceRecordUuid: data.uuid },
                                    path: [record.uuid],
                                }}
                            />
                        ),
                        auditStatus === 0 && (
                            <ModifyDataState
                                key="3"
                                title="销毁"
                                type="auditStatus"
                                upDataEvent={upDataEvent}
                                data={{
                                    api: 'putBeamProduceRecordDetail',
                                    params: { uuid: record.uuid, auditStatus: -1, beamProduceRecordUuid: data.uuid },
                                    path: [record.uuid],
                                }}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === 'fc616397-ebb3-4046-b3f9-7d41df4a65c5') !== -1 && (
                            <ThrDeleteBtn
                                key="delete"
                                record={record.uuid}
                                upDataEvent={upDataEvent}
                                data={{ key: 'delete', url: 'delBeamProduceRecordDetail', title: '删除工序' }}
                            />
                        ),
                    ]
                },
            },
        ],
    }

    return dataList
}
